//
//  FeatureTableViewCell.m
//  UGoods
//
//  Created by dllo on 16/1/16.
//  Copyright © 2016年 蓝鸥科技.李贺. All rights reserved.
//

#import "FeatureTableViewCell.h"
#import "FindModel.h"
#import <UIImageView+WebCache.h>
#import "BaseLabel.h"
#import "BaseView.h"
#import "ConstantsDefine.h"
@interface FeatureTableViewCell ()

@property (nonatomic, retain) UIImageView *coverImageView; /**< 封面图片 */
@property (nonatomic, retain) UILabel *titleLabel; /**< 标题 */
@property (nonatomic, retain) UILabel *subtitleLabel; /**< 子标题 */
@property (nonatomic, retain) UIView *lineView;
@property (nonatomic, retain) UIView *maskView; 


@end

@implementation FeatureTableViewCell

- (void)dealloc
{
    [_coverImageView release];
    [_titleLabel release];
    [_subtitleLabel release];
    [_lineView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.coverImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_coverImageView];
        [_coverImageView release];
        
        self.maskView = [[UIView alloc] init];
        _maskView.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.200];
        [self.coverImageView addSubview:_maskView];
        [_maskView release];
        
        self.titleLabel = [[UILabel alloc] init];
//        _titleLabel.backgroundColor = [UIColor redColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.font = [UIFont boldSystemFontOfSize:18 * WIDTH];
        [self.maskView addSubview:_titleLabel];
        [_titleLabel release];
        
        self.lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor whiteColor];
        [self.maskView addSubview:_lineView];
        [_lineView release];
        
        self.subtitleLabel = [[UILabel alloc] init];
//        _subtitleLabel.backgroundColor = [UIColor redColor];
        _subtitleLabel.textAlignment = NSTextAlignmentCenter;
        _subtitleLabel.textColor = [UIColor whiteColor];
        _subtitleLabel.font = [UIFont systemFontOfSize:15 * WIDTH];
        [self.maskView addSubview:_subtitleLabel];
        [_subtitleLabel release];
        
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _coverImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width,self.contentView.frame.size.height - 10 * HEIGHT);
    _maskView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height - 10 * HEIGHT);
    self.lineView.frame = CGRectMake(0, 0, 20 * WIDTH, 3 * HEIGHT);
    _lineView.center = self.contentView.center;
    _titleLabel.frame = CGRectMake(0, _lineView.frame.origin.y - 40 * HEIGHT, self.contentView.frame.size.width, 30 * HEIGHT);
    _subtitleLabel.frame = CGRectMake(0, _lineView.frame.origin.y + 20 * HEIGHT, self.contentView.frame.size.width, 20 * HEIGHT);
}

- (void)setModel:(FindModel *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [_coverImageView sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:[UIImage imageNamed:@"place"]];
    _titleLabel.text = model.title;
    _subtitleLabel.text = model.subtitle;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
